/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.factory_method.single_factory.lazy;

import com.moses.design_patterns.factory_method.IProduct;
import com.moses.design_patterns.factory_method.ProductA;
import com.moses.design_patterns.factory_method.single_factory.SingletonFactory;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/11 11:26
 */
public class LazySingletonFactory extends SingletonFactory {
    // 如果需要多个，则用集合类来进行缓存
    private static IProduct product = null;

    @Override
    public IProduct getProduct() {
        if(product == null){
            product = new ProductA();
        }
        return product;
    }
}
